#pragma once
#include "ai_global.h"

#include "IInfer.h"

#include <openvino/openvino.hpp>
#include "AIDataDefine.h"



class AI_EXPORT InferOpenVino : public IInfer
{
public:
	InferOpenVino();
	~InferOpenVino();

	int infer(cv::Mat &src);
	InferResult* getInferResult() { return &result_; }
	bool loadModelFile(const char* modelPath);
	bool loadLabelFile(const char* filePath);
	void setParams(float confidence = 0.25, float score = 0.25, float nms = 0.45)
	{
		modelConfidenceThreshold_ = confidence;
		modelScoreThreshold_ = score;
		modelNMSThreshold_ = nms;
	}

	std::string getLastError() { return lastErrorInfo_; }
	std::vector<std::string> getTestOutput() { return testOutputInfos_; }


protected:
	// classesFile
	void parseTextFile(std::string filePath);
	void parseYamlFile(std::string filePath);

	cv::Mat pre_process(cv::Mat* img, int length, float* factor);
	void post_process(float* result, float factor, int outputLength);
	//std::vector<DetResult> post_process_seg(ov::Tensor output0, ov::Tensor output1, float* result, float factor, int outputLength);


private:
	InferResult result_;
	std::string lastErrorInfo_ = "";
	std::vector<std::string> testOutputInfos_;

	float modelConfidenceThreshold_ = 0.25;
	float modelScoreThreshold_ = 0.25;
	float modelNMSThreshold_ = 0.45;

	bool suc_loadModel_ = false;
	bool suc_loadLabel_ = false;

	std::vector<std::string> labels_;

	cv::Mat srcImage_;
	ov::Output<const ov::Node> input_port_;
	ov::InferRequest infer_;
};

